﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using WalkingTec.Mvvm.Core;
using System.Text.Json.Serialization;
using nERP.Model;
using nERP.Model._Admin;
using nERP.Model.Wms;

namespace nERP.Model.Wms
{
    /// <summary>
    /// 其他入库
    /// </summary>
	[Table("OtherInWarehouse")]
    [SoftKey(nameof(OtherInWarehouse.OtherInWarehouseCode))]
    [Display(Name = "_Model.OtherInWarehouse")]
    public class OtherInWarehouse : BasePoco,IPersistPoco,ITenant,IWorkflow
    {
        [Display(Name = "_Model._OtherInWarehouse._OtherInWarehouseCode")]
        [StringLength(32, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("入库单号")]
        [Required(ErrorMessage = "Validate.{0}required")]
        [CanNotEdit]
        public string OtherInWarehouseCode { get; set; }
        [Display(Name = "_Model._OtherInWarehouse._OtherInType")]
        [Comment("业务类别")]
        [RefDicName(Name = "入库业务类别")]
        public DicField OtherInType { get; set; }
        [Display(Name = "_Model._OtherInWarehouse._OtherInType")]
        [Comment("业务类别")]
        public Guid? OtherInTypeId { get; set; }
        [Display(Name = "_Model._OtherInWarehouse._MakeUser")]
        [Comment("制单人")]
        [NotMapped]
        public FrameworkUser MakeUser { get; set; }
        [Display(Name = "_Model._OtherInWarehouse._MakeUser")]
        [StringLength(32, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("制单人")]
        public string MakeUserId { get; set; }
        [Display(Name = "_Model._OtherInWarehouse._InvoicesDate")]
        [Comment("单据日期")]
        public DateTime? InvoicesDate { get; set; }
        [Display(Name = "_Model._OtherInWarehouse._InvoicesImage")]
        [Comment("单据附件")]
        public List<OtherInWarehouseInvoicesImage> InvoicesImage { get; set; }
        [Display(Name = "_Model._OtherInWarehouse._Status")]
        [Comment("单据状态")]
        public StatusTypeEnum? Status { get; set; }
        [Display(Name = "_Model._OtherInWarehouse._Remark")]
        [StringLength(256, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("备注")]
        public string Remark { get; set; }
        [Display(Name = "_Model._OtherInWarehouseDetail._OtherInWarehouse")]
        [InverseProperty("OtherInWarehouse")]
        [NotMapped]
        [SoftFK(nameof(nERP.Model.Wms.OtherInWarehouseDetail.OtherInWarehouseId))]
        public List<OtherInWarehouseDetail> OtherInWarehouseDetail_OtherInWarehouse { get; set; }
        [Display(Name = "_Model._OtherInWarehouse._IsValid")]
        [Comment("是否有效")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public bool IsValid { get; set; } = true;
        [StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
        public string TenantCode { get; set; }

	}
    public class OtherInWarehouseInvoicesImage : TopBasePoco, ISubFile
    {
        public Guid OtherInWarehouseId { get; set; }
        public OtherInWarehouse OtherInWarehouse { get; set; }
        public Guid FileId { get; set; }
        public FileAttachment File { get; set; }
        public int Order { get; set; }
    }

}
